package commands;

import utils.ITransmittable;
import nanoxml.XMLElement;

/**
 * This command represents a notification that a user with the entered username
 * in order to connect or register to the server is already connected.
 */
public class CommandUserAlreadyConnected implements ITransmittable {

	private final static String ATTR_USER_NAME = "Username";
	private final static String ATTR_MESSAGE = "Message";
	
	
	private String username = null; 
	private String message = null;
	
	
	public CommandUserAlreadyConnected (String username, String message) {
		this.username = username;
		this.message = message;
	}
	
	public CommandUserAlreadyConnected (XMLElement command) {
		this.username = (String)command.getAttribute(ATTR_USER_NAME);
		this.message = (String)command.getAttribute(ATTR_MESSAGE);
		
	}
	
	
	@Override
	public XMLElement toXML() {
		XMLElement mes  = new XMLElement();
		mes.setName(Commands.USER_ALREADY_CONNECTED);
		mes.setAttribute(ATTR_USER_NAME, username);
		mes.setAttribute(ATTR_MESSAGE, message);
		return mes;
	}
	
	public String getUsername()
	{
		return username;
	}
	
	public String getMessage()
	{
		return message;
	}
}

